import Vue from 'vue'
import VueRouter from 'vue-router'
// 解决导航栏或者底部导航tabBar中的vue-router在3.0版本以上频繁点击菜单报错的问题。
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location) {
    return originalPush.call(this, location).catch(err => err)
}


Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'user',
    component: () => import('../views/user.vue'),
      redirect: '/userHome',  // 重定向到主页
    children:[
      {path:'userHome',name:'userHome',meta:{name:'用户首页'},component:() => import('../views/user/userHome.vue') },
      {path:'userSave',name:'userSave',meta:{name:'用户收藏'},component:() => import('../views/user/userSave.vue') },
      {path:'hotelList',name:'hotelList',meta:{name:'酒店列表'},component:() => import('../views/user/hotelList.vue') },
      {path:'userOrder',name:'userOrder',meta:{name:'用户订单'},component:() => import('../views/user/userOrder.vue') },
      {path:'hotelDetail',name:'hotelDetail',meta:{name:'酒店详情'},component:() => import('../views/user/hotelDetail.vue') },
      {path:'orderDetail',name:'orderDetail',meta:{name:'订单详情'},component:() => import('../views/user/orderDetail.vue') },
      {path:'points',name:'points',meta:{name:'我的积分'},component:() => import('../views/user/points.vue') },
      {path:'payment',name:'payment',meta:{name:'支付界面'},component:() => import('../views/user/payment.vue') },
      {path:'money',name:'money',meta:{name:'我的钱包'},component:() => import('../views/user/money.vue') },
      {path:'safecenter',name:'safecenter',meta:{name:'账户安全'},component:() => import('../views/user/safecenter.vue') },
      {path:'userInformation',name:'userInformation',meta:{name:'用户信息'},component:() => import('../views/user/userInformation.vue') },
      {path:'login',name:'login',meta:{name:'登录'},component:() => import('../views/login.vue') },
      {path:'Register',name:'Register',meta:{name:'注册'},component:() => import('../views/register.vue') },
      {path:'comment',name:'comment',meta:{name:'我的评论'},component:() => import('../views/user/comment.vue') },
      {path:'myCoupon',name:'myCoupon',meta:{name:'我的优惠券'},component:() => import('../views/user/myCoupon.vue') },
      {path:'historyOrders',name:'historyOrders',meta:{name:'历史记录'},component:() => import('../views/user/historyOrders.vue') },
      {path:'pointsActivity',name:'pointsActivity',meta:{name:'积分活动'},component:() => import('../views/user/pointsActivity.vue') },
    ]
  },
      {
    path: '/business',
    name: 'business',
    redirect: '/business/businessHome',  // 重定向到主页
    component: () => import('../views/business.vue'),
    children: [
        {path:'hotelApplication',name:'hotelApplication',meta:{name:'申请酒店'},component:() => import('../views/business/hotelApplication.vue') },
        {path:'businessHome',name:'businessHome',meta:{name:'商家主页'},component:() => import('../views/business/businessHome.vue') },
        {path:'hotelHome',name:'hotelHome',meta:{name:'酒店主页'},component:() => import('../views/business/hotelHome.vue') },
        {path:'room',name:'room',meta:{name:'房间'},component:() => import('../views/business/room.vue') },
        {path:'orderList',name:'orderList',meta:{name:'酒店订单'},component:() => import('../views/business/orderList.vue') },
        {path:'evaluate',name:'evaluate',meta:{name:'用户评价'},component:() => import('../views/business/evaluate.vue') },
        {path:'offlineOrders',name:'offlineOrders',meta:{name:'线下订单'},component:() => import('../views/business/offlineOrders.vue') },
        {path:'offlineDetail',name:'offlineDetail',meta:{name:'填写线下客户消息'},component:() => import('../views/business/offlineDetail.vue') },
        {path:'offlinePayment',name:'offlinePayment',meta:{name:'线下订单支付'},component:() => import('../views/business/offlinePayment.vue') },
        {path:'roomDetail',name:'roomDetail',meta:{name:'房间详情'},component:() => import('../views/business/roomDetail.vue') },
        {path:'roomAdd',name:'roomAdd',meta:{name:'新增房间'},component:() => import('../views/business/roomAdd.vue') },
        {path:'online',name:'online',meta:{name:'新增房间'},component:() => import('../views/business/online.vue') },
        {path:'offline',name:'offline',meta:{name:'新增房间'},component:() => import('../views/business/offline.vue') },
        {path:'recordOrder',name:'recordOrder',meta:{name:'历史订单'},component:() => import('../views/business/recordOrder.vue') },
        {path:'dailyIncome',name:'dailyIncome',meta:{name:'酒店日收入'},component:() => import('../views/business/dailyIncome.vue') },
        {path:'pointsApplication',name:'pointsApplication',meta:{name:'活动申请'},component:() => import('../views/business/pointsApplication.vue') },
    ]
  },
          {
    path: '/manage',
    name: 'manage',
    redirect: '/manage/manageHome',  // 重定向到主页
    component: () => import('../views/manage.vue'),
    children: [
        {path:'manageHome',name:'manageHome',meta:{name:'管理员主页'},component:() => import('../views/manage/manageHome.vue') },
         {path:'hotelApply',name:'hotelApply',meta:{name:'酒店申请'},component:() => import('../views/manage/hotelApply.vue') },
         {path:'businessManage',name:'businessManage',meta:{name:'商家信息管理'},component:() => import('../views/manage/businessManage.vue') },
         {path:'userList',name:'userList',meta:{name:'用户信息管理'},component:() => import('../views/manage/userList.vue') },
         {path:'evaluateManage',name:'evaluateManage',meta:{name:'用户评价管理'},component:() => import('../views/manage/evaluateManage.vue') },
         {path:'hotelRoomDetail',name:'hotelRoomDetail',meta:{name:'酒店详情'},component:() => import('../views/manage/hotelRoomDetail.vue') },
         {path:'coupon',name:'coupon',meta:{name:'优惠券'},component:() => import('../views/manage/coupon.vue') },
         {path:'income',name:'income',meta:{name:'酒店日收入'},component:() => import('../views/manage/income.vue') },
         {path:'orders',name:'orders',meta:{name:'酒店订单表'},component:() => import('../views/manage/orders.vue') },
         {path:'userMoney',name:'userMoney',meta:{name:'用户余额'},component:() => import('../views/manage/userMoney.vue') },
         {path:'userPoints',name:'userPoints',meta:{name:'用户积分'},component:() => import('../views/manage/userPoints.vue') },
         {path:'userSaves',name:'userSaves',meta:{name:'用户收藏'},component:() => import('../views/manage/userSaves.vue') },
         {path:'userCoupons',name:'userCoupons',meta:{name:'用户优惠券'},component:() => import('../views/manage/userCoupons.vue') },
         {path:'unusableCoupons',name:'unusableCoupons',meta:{name:'已废弃优惠券'},component:() => import('../views/manage/unusableCoupons.vue') },
         {path:'recommend',name:'recommend',meta:{name:'首页推荐'},component:() => import('../views/manage/recommend.vue') },
         {path:'income',name:'income',meta:{name:'酒店收入'},component:() => import('../views/manage/income.vue') },
         {path:'registerCount',name:'registerCount',meta:{name:'用户日注册数'},component:() => import('../views/manage/registerCount.vue') },
         {path:'hotelDetailList',name:'hotelDetailList',meta:{name:'酒店详情'},component:() => import('../views/manage/hotelDetailList.vue') },
         {path:'hotelactive',name:'hotelactive',meta:{name:'酒店活动审核'},component:() => import('../views/manage/hotelactive.vue') },
         {path:'activeList',name:'activeList',meta:{name:'参与酒店'},component:() => import('../views/manage/activeList.vue') },
         {path:'useractive',name:'useractive',meta:{name:'参与用户'},component:() => import('../views/manage/useractive.vue') },
         {path:'number',name:'number',meta:{name:'统计参与数量'},component:() => import('../views/manage/number.vue') },
    ]
  },
  {
    path: '/test',
    name: 'test',
    component: () =>import ('../views/test.vue'),
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
